package com.admin.controller.base;

import com.admin.domain.Region;
import com.admin.service.RegionsService;
import com.admin.vo.ResultVO;
import io.swagger.annotations.*;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(description = "地区接口")
@RestController
@RequestMapping(value = "/region")
public class RegionController {

    @Resource
    private RegionsService regionsService;

    @PostMapping("/getAllCountry")
    @ApiOperation("获取国家,省,市,县接口")
    public ResultVO<List<Region>> getAllCountry(
            @ApiParam(required = false, name = "parent_id", value = "要查询的父级id,国家,省,市可以作为父级,对应的市父级的region_tao_id") @RequestParam(required = false ,value = "parent_id") Integer parent_id
    ){
        Region regions=new Region();
        if (parent_id == null){
            parent_id = 0;
//            regions.setRegionId(12);
        }
        regions.setParentId(parent_id);
        return regionsService.getAllCountry(regions);
    }
}

